import os

class Config:
    # JWT
    SECRET_KEY = os.getenv('JWT_SECRET', 'default_super_secret')
    ADMIN_MASTER_KEY = os.getenv('ADMIN_MASTER_KEY', 'admin_system_master_key_2024')
    TOKEN_EXPIRE_HOURS = 24
    
    # Redis
    REDIS_HOST = os.getenv('REDIS_HOST', 'localhost')
    REDIS_PORT = 6379
    REDIS_DB = 0
    REDIS_PASSWORD = '123456'
    TICKET_EXPIRE_SECONDS = 300
    
    # MySQL
    MYSQL_HOST = 'localhost'
    MYSQL_PORT = 3306
    MYSQL_USER = 'Smart_Sounddb'
    MYSQL_PASSWORD = '123456'
    MYSQL_DB = 'Smart_Sounddb'
    MYSQL_CHARSET = 'utf8mb4'

    # MongoDB配置
    MONGODB_URI = "mongodb://fourzkw:123456@localhost:27017/smartsound"
    MONGODB_DB = "smartsound"
    
    # MongoDB 集合配置
    # 在MONGODB_COLLECTIONS字典中添加
    MONGODB_COLLECTIONS = {
        "device_status": "device_status",
        "device_bind_logs": "device_bind_logs",
        "user_logs": "user_logs",
        "listen_records": "listen_records",
        "daily_preferences": "daily_preferences",
        "monthly_preferences": "monthly_preferences",
        "yearly_preferences": "yearly_preferences",
        "daily_duration": "daily_duration",
        "monthly_duration": "monthly_duration",
        "yearly_duration": "yearly_duration",
        "daily_period_stats": "daily_period_stats",
        "monthly_period_stats": "monthly_period_stats",
        "yearly_period_stats": "yearly_period_stats", 
        "admin_logs": "admin_logs",
        "user_feedback": "user_feedback",
        "feedback_replies": "feedback_replies",
        "announcements": "announcements",
        "user_announcement_reads": "user_announcement_reads"
    }
    
    # 错误代码
    ERROR_CODES = {
        'INVALID_JSON': (40001, "请求必须为JSON格式"),
        'MISSING_FIELD': (40002, "缺少必要字段"),
        'INVALID_DEVICE_ID': (40006, "Invalid device ID format"),
        'DUPLICATE_USER': (40010, "用户名已存在"),
        'AUTH_FAILED': (40100, "认证失败"),
        'UNKNOWN_DEVICE': (40101, "Unknown device ID"),
        'INVALID_SIGNATURE': (40102, "Signature verification failed"),
        'EXPIRED_TIMESTAMP': (40103, "Expired timestamp"),
        'INVALID_TICKET': (40104, "Invalid ticket"),
        'DEVICE_MISMATCH': (40105, "Device ID mismatch"),
        'INVALID_REFRESH_TOKEN': (40108, "Invalid refresh token"),
        'TOO_MANY_REQUESTS': (42901, "Too many requests"),
        'SERVICE_UNAVAILABLE': (50301, "Service unavailable"),
        'DEVICE_NOT_BOUND': (40109, "Device not bound"),
        'UNAUTHORIZED_OPERATION': (40301, "Unauthorized operation"),
        'INVALID_SECRET': (40302, "设备密钥验证失败"),
        'DATABASE_ERROR': (50001, "数据库服务异常"),
        'INVALID_USER_OR_STYLE': (40007, "Invalid user_id or style_name"),
        'INVALID_BATTERY': (40011, "Invalid battery level"),
        'INVALID_NET_DELAY': (40012, "Invalid network delay"),
        'DATA_PROCESSING_ERROR': (50001, "Data processing error"),
        'INVALID_PAGINATION_PARAM': (40010, '无效的分页参数'),
        'INVALID_SORT_METHOD': (40016, '无效的排序方法')
    }

    # DeepSeek API配置
    DEEPSEEK_API_KEY = "sk-e6cb48c91d0f4b769e220a404e6cfc91"

    # 微信小程序配置
    WECHAT_APPID = "wx9ae990eb23012f28"
    WECHAT_SECRET = "1507b3629c7a3c69ab4e69a4f139c6b7"